#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>



int main(){
    char buf[32] = {0};
    mkfifo("test", S_IFIFO | 0666);
    int fd1 = open("test", O_WRONLY);
    int fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0666);
    while(1){
        read(fd1, buf, sizeof(buf));
        write(fd, buf, strlen(buf) + 1);
        for(int i = 0; i < strlen(buf); i++){
            if(buf[i] = '\0')
                break;
        }
    }

    return 0;
}